package com.bangdream.michelia.view.activity.currency;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import com.bangdream.michelia.R;
import com.bangdream.michelia.application.AppCurrentUser;
import com.bangdream.michelia.utils.SPUtils;
import com.nanchen.compresshelper.StringUtil;

public class SplashActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        final String token = AppCurrentUser.getInstance().getToken();
        final String userName = (String) SPUtils.get(SplashActivity.this, "userName", "");
        new Handler().postDelayed(new Runnable() {
            public void run() {
                if (StringUtil.isEmpty(token) || StringUtil.isEmpty(userName)) {
                    startActivity(new Intent(SplashActivity.this,LoginActivity.class));
                }else{
                    startActivity(new Intent(SplashActivity.this,MainActivity.class));
                }
                finish();
            }
        }, 1000);
    }

}